package com.wst.system.controller;

import com.alibaba.fastjson2.JSONObject;
import com.wst.system.config.exception.GlobalExcetion;
import com.wst.system.security.entity.SysUserRoleEntity;
import com.wst.system.security.entity.dto.SysUserRoleEntityDto;
import com.wst.system.security.entity.vo.SysUserRoleEntityVo;
import com.wst.system.server.service.SysUserRoleService;
import com.wst.system.util.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/userrole")
public class SysUserRoleController {

    @Autowired
    private SysUserRoleService sysUserRoleService;

    @PostMapping("save")
    public JSONObject save(@RequestBody @Validated SysUserRoleEntityVo vo) throws GlobalExcetion {
        sysUserRoleService.saveUserRole(vo);
        return ResultUtil.successInfo();
    }

    @GetMapping("/getbyuid")
    public JSONObject getbyuid(@RequestParam("uid") String uid) throws GlobalExcetion {
        List<SysUserRoleEntityDto> list=sysUserRoleService.selectUserRoleEntityDtoByUid(uid);
        return ResultUtil.successInfo(list);
    }
}
